'zSetAttr Status Value "Select SAVE when done entering an address"'
RETURN 0
/* Save button pressed */
Save_Select:
/* Show them that something is going on */
'zDoMethod ZAddress Lock'
/* Get the fields from the window */
'zGetAttr Main Fields fields.'
/* See if the record already exists */
'zPersist Get "'fields.name'"'
IF RESULT="RESULT" THEN DO
/* Didn't already exist, so add it to our index */
'zDoMethod Names Add' fields.name
'zSetAttr Names Value' fields.name
END
/* Build the record */
record=fields.name
record=record||'|'||fields.company
record=record||'|'||fields.address
record=record||'|'||fields.city
record=record||'|'||fields.state
record=record||'|'||fields.zip
record=record||'|'||fields.work
record=record||'|'||fields.home
record=record||'|'||fields.internet
record=record||'|'||fields.bix
/* Save the record */
'zPersist Set "'fields.name'"' record
/* Unlock the UI */
'zDoMethod ZAddress Unlock'
'zSetAttr Status Value "Select NEW to start entering an address"'
RETURN 0
/* Delete button pressed */
Delete_Select:
/* Show them that something is going on */
'zDoMethod ZAddress Lock'
'zGetAttr Main Fields fields.'
record=""
'zPersist Set "'fields.name'"' record
'zDoMethod Names Remove' fields.name
/* Unlock the UI */
'zDoMethod ZAddress Unlock'
RETURN 0
/* They want to see the company information */
GetComp_Select:
'zGetAttr Company Value'
'zSetAttr Names Value' RESULT
RETURN 0
/* They want to go back to the previous name */
Previous_Select:
'zSetAttr Names Value' old.name
RETURN 0
/* ListView changed */
Names_Change:
/* Show them that something is going on */
'zDoMethod ZAddress Lock'
/* Get the current name */
'zGetAttr Names Value'
IF RESULT~=fields.name THEN DO
/* Save the previous name */
old.name=fields.name
/* Now show the name they selected */
fields.name=RESULT
IF LENGTH(fields.name)>0 THEN CALL UpdateRecord
IF LENGTH(fields.name)=0 THEN CALL New_Select
END
/* Unlock the UI */
'zDoMethod ZAddress Unlock'
RETURN 0
UpdateRecord:
'zPersist Get "'fields.name'"'
record=RESULT
PARSE VAR record fields.name'|'fields.company'|'fields.address'|'fields.city'|'fields.state'|'fields.zip'|'fields.work'|'fields.home'|'fields.internet'|'fields.bix
fields.names=fields.name
'zSetAttr Main Fields fields.'
RETURN
CompanyS_Change:
'zGetAttr Names ItemStem Items.'
'zSetAttr NameList ItemStem Items.'
'zDoMethod NameList Add ""'
'zGetAttr Company Value'
IF RESULT~="" THEN 'zSetAttr NameList Value' RESULT